<template>
  <div class="member">
    <div class="header-con">
      <router-link :to="{ name: 'login' }" class="mui-navigate-right">
        <div class="user-info">
          <div>我的</div> <!-- 之前第一段代码里的文本所在div -->
        </div>
      </router-link>
    </div>
    <div class="login">
      <div class="mui-content">
        <form class="mui-input-group">
          <div class="mui-input-row">
            <label>账号</label>
            <input v-model="loginForm.username" type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
          </div>
          <div class="mui-input-row">
            <label>密码</label>
            <input v-model="loginForm.password" type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
          </div>
        </form>
        <div class="mui-content-padded">
          <button @click="login" type="button" class="mui-btn mui-btn-block mui-btn-primary">登录</button>
          <div class="link-area"><a @click="register">还没有账号？前往注册</a></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      loginForm: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    login () {
      // 登录逻辑，后续可以补充如发送请求验证账号密码等操作
     return new Promise((resolve,reject) =>{

      setTimeout(()=>{const res={data:{msg:"登陆成功",
        data:{
          user:{username:this.loginForm.username}
        }
      }
      };
      // 登录成功
this.$store.commit('user/setUser', res.data.data)
this.$auth.setAuthorization(res.data.data.session_id)
this.$toast(res.data.msg)
this.$router.replace({ name: 'user' })
resolve(res);
      },1000)
     });

    },

    register () {
      this.$router.push({ name: 'register' })
    }
  }
}
</script>

<style lang="scss" scoped>
.mui-input-group {
  margin-top: 10px;
  background-color: transparent;
}
.mui-input-group label {
  width: 22%;
}
.mui-input-row:last-child {
  background: #fff;
}
.mui-input-row {
  margin-top: 20px;
  background: #fff;
}
.mui-input-row label~input,
.mui-input-row label~select,
.mui-input-row label~textarea {
  width: 78%;
}
.link-area {
  display: block;
  margin-top: 25px;
  text-align: center;
}
.mui-content-padded {
  margin-top: 30px;
}
/* 可以添加针对外层.member 等类相关的样式，此处暂未详细扩展 */
.member {
  /* 示例样式，可根据实际需求调整 */
  padding: 20px;
}
.header-con {
  margin-bottom: 20px;
}
</style>